package insight.chain.validation;

import insight.chain.exception.ValidatorException;

/**
 * @author huu
 * @create 2025-08-25-18:51
 */
public class MinValidatorHandler implements ValidatorHandler{
    private int min;

    public MinValidatorHandler(int min) {
        this.min = min;
    }

    @Override
    public void validate(Object value,  ValidatorContext context) {
        Object name = context.get("name");
        if(name != null){
            System.out.println(name + "是校验员");
        }
        if(value instanceof Integer intValue){
            if(intValue < min){
                //throw new ValidatorException("min value is " + min);
                context.appendError("min value is " + min);
            }
            context.donext(10);
        }

    }
}
